import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/widgets.dart' hide Action;

import 'package:school_safe_teacher/constans/all_info.dart';
import 'package:school_safe_teacher/constans/route_constants.dart';
import 'package:school_safe_teacher/utils/cache_utils.dart';
import 'package:school_safe_teacher/utils/sp_utils.dart';

import 'action.dart';
import 'state.dart';
import 'package:rammus/rammus.dart' as rammus;

Effect<SettingState> buildEffect() {
  return combineEffects(<Object, Effect<SettingState>>{
    SettingAction.action: _onAction,
    SettingAction.logout: _logout,
  });
}

void _onAction(Action action, Context<SettingState> ctx) {}

void _logout(Action action, Context<SettingState> ctx) {
  clearApplicationCache();
  AllInfo.instance.setToken("");
  AllInfo.instance.setUserinfo("");


  AllInfo.instance.setPhone("");
  // Alipush.instance.unbindAccount();
  rammus.unbindAccount();
  SpUtil.clear();
  Navigator.of(ctx.context).pushNamedAndRemoveUntil(
      RouteConstants.LOGIN, ModalRoute.withName(RouteConstants.LOGIN));
}
